<%@ page language="java" import="java.util.*,com.king.cms.common.*"
	pageEncoding="utf-8"%>
<%@ include file="/hotel/include/css.jsp"%>
<%-- /*包含css样式表*/ --%>
<%@ include file="/hotel/info/date.jsp"%>
<%-- /*包含css样式表*/ --%>
<%
   int pow=(PowerParameter.save | PowerParameter.cls | PowerParameter.list|PowerParameter.inquiry);
     Map map = (Map)request.getAttribute("dataMap"); 
     if(null == map)
          map = new HashMap();
     List dishs = (List)request.getAttribute("dishs");
     List selecteddishs = (List)request.getAttribute("selecteddishs");
     if(selecteddishs ==null)
    	 selecteddishs = new ArrayList();
     String selectStr = (String)request.getAttribute("selectStr");
     String relationship = (String)request.getAttribute("relationship");
     //选择播放地点相关信息
     String nameStr = (String)request.getAttribute("nameStr");
     String idStr = (String)request.getAttribute("idStr");
     String contentStr = (String)request.getAttribute("contentStr");
     String areaStr = (String)request.getAttribute("areaStr");
%>
<html xmlns:MSIE='http://www.microsoft.com/ie'>
	<head>
		<title></title>
		<style>   
    
  @media   all   
  {   
  MSIE\:CLIENTCAPS{behavior:url(#default#clientcaps)}   
  }   
  </style>
		<meta http-equiv="Expires" CONTENT="0">
		<meta http-equiv="Cache-Control" CONTENT="no-cache">
		<meta http-equiv="Pragma" CONTENT="no-cache">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<script language="JavaScript" src="<%=path%>/js/generalcheck.js"></script>
		<script language="javascript">
//added by shangchm  添加对应关系
   function moveOption(from,to,isCut){
	    var fromCom1 = document.getElementById(from);//select
	    var toCom = document.getElementById(to);    //select
	    if(fromCom1==null||toCom==null){
	        return;
	    }
	    var index1 = fromCom1.options.selectedIndex;  
	    var tempValue;
	    var tempText;
	    if(index1!=-1){
	        with(fromCom1){
	            tempValue =options[options.selectedIndex].value + "--"+options[options.selectedIndex].text + "|" ;
	            tempText =  options[options.selectedIndex].text ; 
				if(isCut){
	                options.remove(index1);
	            }  
	        }
	        with(toCom){
	            var newOption = document.createElement('OPTION');
	            newOption.value = tempValue;
	            newOption.text = tempText;
	            options.add(newOption);
	        }   
	        document.forms[0].sendReceiveItemRelationship.value = document.forms[0].sendReceiveItemRelationship.value + tempValue;
	        //alert(document.forms[0].sendReceiveItemRelationship.value);
	    }
	}
	
	//added by shangchm  移除对应关系
	function moveBackOption(from,to){
		var fromCom = document.getElementById(from);
		var toCom1 = document.getElementById(to);
		if(fromCom==null||toCom1==null){
			return;
		}
		var index = fromCom.options.selectedIndex;
		var myTemp ;
		var tempValue;
		var tempText;
        if(index!=-1){
			with(fromCom){
			    myTemp = options[options.selectedIndex].value;
				var temp = myTemp.substr(0,myTemp.length-1);
				var part = temp.split("--");
				tempValue = part[0];
				tempText = part[1];
                options.remove(index);				
			}
			with(toCom1){
				var newOption = document.createElement('OPTION');
			    newOption.value = tempValue;
				newOption.text = tempText;
				options.add(newOption);
			}
		var tempValues = document.forms[0].sendReceiveItemRelationship.value;
        document.forms[0].sendReceiveItemRelationship.value = tempValues.replace(myTemp,"");
		}
		 //alert(document.forms[0].sendReceiveItemRelationship.value);
	}
 function selectRoom(){
 	var str =  form1.placeselect.value;
 	if(''!= str){
 	  var index = str.indexOf('#');
 	  var areaId = str.substring(0,index);
 	  var type = str.substring(index+1); 
 	  if(0 == type)
 	    openwindow('<%=path%>/client.do?action=select&type=3&area='+areaId+'&meetingId=<%=map.get("ID")%>','1024','768','_blank');
 	 
 	   
 	}     
 }
 
 function ki_list(){
		window.open('<%=basePath%>info.do?action=list','_self');
	}
 function ki_inquiry(){
		    openwindow("<%=path%>/pubinfo.do?action=search",'800','600','');
		}
		
  function saveData(){ 
    if(checkData()){
     form1.action="<%=path%>/mult/controlAction.do?action=save&infoType=3";
     form1.submit();
    }
   }
  function ki_save(){ 
	 saveData();
	} 
	
	function checkData(){ 
      if(!validateNotNull(document.getElementById("infoName"),'菜单名称'))
	     return false;
    if(!validateNotNull(document.getElementById("infoStartTime"),'菜单播放起始时间'))
    	return false;
    if(!validateNotNull(document.getElementById("infoEndTime"),'菜单播放结束时间'))
    	return false;
    if(document.getElementById("infoStartTime").value >= document.getElementById("infoEndTime").value){
       alert("文件播放结束时间不能早于或等于开始时间");
       return false;
    }
     if(!validateNotNull(document.getElementById("sendReceiveItemRelationship"),'选择的菜肴')){
	     return false; 
	  }
     if(!validateNotNull(document.getElementById("template"),'菜肴模板')){
	     return false; 
	  }
	  if(!validateNotNull(document.getElementById("hytzPort"),'发布地点')){
	     return false; 
	  }
 
   
    return true; 
 } 
 
 function ki_cls(){
		 document.getElementById("infoName").value='';
		 document.getElementById("infoStartTime").value='';
		 document.getElementById("infoEndTime").value='';
		 document.getElementById("template").value='';
		 document.getElementById("hytzPort").value='';
		 document.getElementById("hytzPortName").value='';
		 document.getElementById("placeselect").value=''
	} 
 
</script>
		<style type="text/css">
<!--
.STYLE2 {color: #FF0000}
-->
</style>
	</head>

	<body background="<%=imgpath%>top3.gif" leftmargin="0" topmargin="0">
		<MSIE:CLIENTCAPS ID='idClient' />
		<script language='javascript'>   
    
  <!--   
  width = idClient.availWidth;
  height =  idClient.availheight;    
    
  -->   
    
  </script>
		<br>
		<form name="form1" action="" method="post">

			<center>
				<table border="0" cellpadding="2" cellspacing="1" class="bg_table"
					style="width:80%" bordercolor="#111111">
					<tr class="top_td">
						<td colspan="3"></td>
						<input type="hidden" name="sendReceiveItemRelationship" id="sendReceiveItemRelationship" value="<%=relationship==null?"":relationship%>">
					</tr>
					<tr class="td2">
						<td width="20%" style="height:30px">
							发布类型
						</td>
						<td width="30%">
							菜单模式
							<input type="hidden" name="infoType" id="infoType" value="3">
						</td>
						<td width="50%"">
							请选择菜肴
						</td>
					</tr>
					<tr class="td2">
						<td>
							菜单名称
						</td>
						<td>
							<input type="hidden" name="meetingId"  class="area100" check="c_y_200" maxlength="30" style="width:90%" value="<%=StringUtil.NULL2Blank(map.get("ID")+"") %>" >
							<input type="text" name="infoName" id="infoName" class="area100" check="c_y_200" maxlength="30" style="width:90%" value="<%=StringUtil.NULL2Blank(map.get("MEETING_NAME")+"") %>" 
						</td>
						<td rowspan="7">
							<table width="100%" height="100%" border="0">
								<tr>
									<td width="45%" rowspan="2">
										<select style="width:180px" name="from" id="from" size="15">
										 <% 
										    for(int i=0;i<dishs.size();i++){
										    	Map dishMap = (Map)dishs.get(i);
										 %>
										    <option value="<%=dishMap.get("ID") %>"><%=dishMap.get("DISH_NAME")+"("+dishMap.get("DISH_TYPE")+")" %></option>       
										 <%} %>
										</select>
									</td>
									<td width="10%">
										<input type="button" name="add" class="area100" value="添加"
											onClick='javascript:moveOption("from","to",true)'>
									</td>
									<td width="45%" rowspan="2">
										<select style="width:180px" name="to" id="to" size="15">
										 <% 
										    for(int i=0;i<selecteddishs.size();i++){
										    	Map selectedDishmap = (Map)dishs.get(i);
										 %>
										    <option value="<%=selectedDishmap.get("DISH_ID") %>"><%=selectedDishmap.get("DISH_NAME") %></option>       
										 <%} %>
										</select>
									</td>
								</tr>
								<tr>
									<td>
										<input type="button" class="area100" name="del" value="删除"
											onClick='javascript:moveBackOption("to","from")'>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr class="td2">
						<td>
							菜单播放开始时间
						</td>
						<td>
							<input type="text" name="infoStartTime" id="infoStartTime" class="area100"
								check="c_n_200" style="width:90%"
								value="<%=StringUtil.dateTimeSubStr(map.get("MEETING_BEGIN_TIME")
							+ "")%>"
								onClick="changediv(this);changeshow2Sj(this);" readonly>
						</td>
					</tr>
					<tr class="td2">
						<td>
							菜单播放结束时间
						</td>
						<td>
							<input type="text" name="infoEndTime" id="infoEndTime" class="area100"
								check="c_n_200" style="width:90%"
								value="<%=StringUtil.dateTimeSubStr(map.get("MEETING_END_TIME")
							+ "")%>"
								onClick="changediv(this);changeshow2Sj(this);" readonly>
						</td>
					</tr>
					<tr class="td2">
						<td>
							菜单模板
						</td>
						<td>
							<%=selectStr%>
						</td>
					</tr>
					<tr class="td2">
						<td>
							发布人
						</td>
						<td>
							 <input type="hidden" name="publishId" value="<%if(null == map.get("MEETING_PUBLISH_ID")||"null".equals(map.get("MEETING_PUBLISH_ID")+"")){out.print(SessionUtil.getUserId(request));} else{ out.print(StringUtil.NULL2Blank(map.get("MEETING_PUBLISH_ID")+""));}%>"><%if(null == map.get("MEETING_PUBLISH_ID")||"null".equals(map.get("MEETING_PUBLISH_ID")+"")){out.print(SessionUtil.getUserName(request));}else{ out.print(InitSystem.getUserNameById(map.get("MEETING_PUBLISH_ID")+""));}%>
						</td>
					</tr>
					<tr class="td2">
						<td colspan="2">
							请选择发布地点
						</td>
					</tr>
					<tr class="td2">
						<td colspan="2">
						    <input type="hidden" name="fieldflag" value="0">
							<input type="hidden" name="hytzPort"        value="<%=StringUtil.NULL2Blank(idStr)==null?"":StringUtil.NULL2Blank(idStr) %>"  >
                            <input type="text" name="hytzPortName"  id="hytzPortName"  class="area100"  style="width:50%"  value="<%=StringUtil.NULL2Blank(nameStr)==null?"":StringUtil.NULL2Blank(nameStr) %>" readonly>
                            <input type="hidden" name="content"        value="<%=StringUtil.NULL2Blank(contentStr) %>" >
                            <%=areaStr%>
						</td>
					</tr>
					<tr class="top_td">
						<td colspan="3">
						</td>
					</tr>
				</table>
			</center>
		</form>

	</body>
</html>
<%@ include file="/hotel/pow.jsp"%>
